package com.application.mylibrary.widget;

import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;




/**
 * Created by lixuce on 2017/8/3.
 * action :刷新控件
 */

public class RefreshView extends SwipeRefreshLayout implements SwipeRefreshLayout.OnRefreshListener {
    private RefreshListener mListener;

    public RefreshView(Context context) {
        super(context);
    }

    public RefreshView(Context context, AttributeSet attrs) {
        super(context, attrs);
        //解决部分机型获取不到资源
    }

    public void setRefreshListener(RefreshListener listener) {

        if (listener != null) {
            this.mListener = listener;
            setOnRefreshListener(this);
        }
    }




    @Override
    public void onRefresh() {
        if (mListener != null) {
            mListener.onRefresh();
        }
    }

    public interface RefreshListener {
        void onRefresh();
    }

    public void setFinish() {
        if (isRefreshing())
            this.setRefreshing(false);

    }
}

